﻿/** * com.sekati.demo.ContentBox * @version 1.0.0 * @author jason m horwitz | sekati.com * Copyright (C) 2007  jason m horwitz, Sekat LLC. All Rights Reserved. * Released under the MIT License: http://www.opensource.org/licenses/mit-license.php */import com.sekati.core.App;import com.sekati.ui.Scroll;import com.sekati.utils.Delegate;import com.sekati.display.CoreClip;
/** * ContentBox demo implementation of {@link com.sekati.ui.Scroll} */class com.project.ui.ContentBox extends CoreClip {
	public var _mask:MovieClip;	public var _content:MovieClip;	public var _scrollbar:MovieClip;	public var _tracker:MovieClip;	public var _scroll:Object;	public var _btn0:MovieClip;	public var _btn1:MovieClip;	public var _btn2:MovieClip;	public var _acBtn:MovieClip;	public var _slideBtn:MovieClip;
	// constructor	private function ContentBox() {	}
	public function configUI():Void {		_mask = _this.mask;		_content = _this.contents;		_tracker = _this.contents;		_scrollbar = _this.scrollbar;		_btn0 = _this.btn0;		_btn1 = _this.btn1;		_btn2 = _this.btn2;		_acBtn = _this.acBtn;		_slideBtn = _this.slideBtn;		// setup		App.bc.subscribe( _this );		_content.tf.autoSize = true;		_content.tf.html = true;		// note: content y is always 0 for Scroller class		_content._y = 0;		// button setup and events		_btn0.tf.text = "page 1";		_btn1.tf.text = "page 2";		_btn2.tf.text = "page 3";		_acBtn.tf.text = "addTxt";		_slideBtn.tf.text = "slide";		_btn0.onRelease = Delegate.create( _this, btn0_onRelease );		_btn1.onRelease = Delegate.create( _this, btn1_onRelease );		_btn2.onRelease = Delegate.create( _this, btn2_onRelease );		_acBtn.onRelease = Delegate.create( _this, acBtn_onRelease );		_slideBtn.onRelease = Delegate.create( _this, slideBtn_onRelease );	}
	private function onAppConfigured():Void {		App.log.trace( this, "* initializing ContentBox" );		_content.tf.htmlText = App.db.data.copy_1.data;		_this.initScroller( );	}
	private function initScroller():Void {		//axis:String, content:Object, mask:MovieClip, gutter:MovieClip, scroller:MovieClip, isResizeGutter:Boolean, isResizeScroller:Boolean, isInit:Boolean, contentSizeTracker:Object, friction:Number, ratio:Number, colors:Objec		_scroll = new Scroll( "_y", _content, _mask, _scrollbar.gutter, _scrollbar.bar, true, true, true, true, _tracker, .8, .5, {up:0xFFFFFF, over:0xFFCC00} );	}
	private function resetScroller():Void {		_scroll = null;		_scrollbar.bar._y = 0;		_content._y = 0;		initScroller( );	}
	public function setContent(copy:String):Void {		_content.tf.htmlText = copy;		resetScroller( );	}
	private function btn0_onRelease():Void {		setContent( App.db.data.copy_1.data );	}
	private function btn1_onRelease():Void {		setContent( App.db.data.copy_2.data );	}
	private function btn2_onRelease():Void {		setContent( App.db.data.copy_3.data );	}
	private function acBtn_onRelease():Void {		_content.tf.htmlText += App.db.data.copy_1.data + "\n\n---------------------------------------\n\n" + _content.tf.htmlText + "\n\n-----------------------------------------\n\nEOF";	}
	private function slideBtn_onRelease():Void {		_scroll.slideContent( 500 );	}}